package com.liaoban.app.ui.anchor;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.liaoban.app.R;
import com.liaoban.app.constants.ExtraParam;
import com.liaoban.app.helper.ImageHelper;
import com.liaoban.app.ui.base.BaseFragment;

import butterknife.BindView;

/**
 * Created by ybc on 2018/8/6 0006.
 */
public class GalleryImageFragment extends BaseFragment {
    @BindView(R.id.iv_pic)
    public ImageView image;

    private String url;

    public static GalleryImageFragment newInstance(String url) {
        GalleryImageFragment fragment = new GalleryImageFragment();
        Bundle bundle = new Bundle();
        bundle.putString(ExtraParam.URL, url);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    protected int getLayoutResID() {
        return R.layout.fragment_gallery_image;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        url = getArguments().getString(ExtraParam.URL);
    }

    @Override
    protected void initView(View contentView) {
        ImageHelper.load(image, url);
        image.setOnClickListener(view -> getActivity().finish());
    }
}
